home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / gcc / gcc261c.zoo / objects / objc-malloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-19  |  1.8 KB  |  45 lines

  1. /* Memory allocation definitions for Objective-C, easy garbage collection.
  2.    Copyright (C) 1993,1994 Free Software Foundation, Inc.
  3.  
  4.    Written by:  R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
  5.    Date: May 1993
  6.  
  7.    This file is part of the GNU Objective C Class Library.
  8.  
  9.    This library is free software; you can redistribute it and/or
  10.    modify it under the terms of the GNU Library General Public
  11.    License as published by the Free Software Foundation; either
  12.    version 2 of the License, or (at your option) any later version.
  13.    
  14.    This library is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17.    Library General Public License for more details.
  18.  
  19.    You should have received a copy of the GNU Library General Public
  20.    License along with this library; if not, write to the Free
  21.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */ 
  23.  
  24. #ifndef __objc_malloc_h_INCLUDE_GNU
  25. #define __objc_malloc_h_INCLUDE_GNU
  26.  
  27. /* I do this to make substituting Boehm's Garbage Collection easy. */
  28. extern void *(*objc_malloc)(size_t);
  29. extern void *(*objc_atomic_malloc)(size_t);
  30. extern void *(*objc_realloc)(void *, size_t);
  31. extern void *(*objc_calloc)(size_t, size_t);
  32. extern void (*objc_free)(void *);
  33.  
  34. #define OBJC_MALLOC(VAR, TYPE, NUM) \
  35.    ((VAR) = (TYPE *) (*objc_malloc)((unsigned)(NUM)*sizeof(TYPE))) 
  36. #define OBJC_ATOMIC_MALLOC(VAR, TYPE, NUM) \
  37.    ((VAR) = (TYPE *) (*objc_atomic_malloc)((unsigned)(NUM)*sizeof(TYPE))) 
  38. #define OBJC_REALLOC(VAR, TYPE, NUM) \
  39.    ((VAR) = (TYPE *) (*objc_realloc)((VAR), (unsigned)(NUM)*sizeof(TYPE)))
  40. #define OBJC_CALLOC(VAR, TYPE, NUM) \
  41.    ((VAR) = (TYPE *) (*objc_calloc)((unsigned)(NUM), sizeof(TYPE)))
  42. #define OBJC_FREE(PTR) (*objc_free)((PTR))
  43.  
  44. #endif /* __objc_malloc_h_INCLUDE_GNU */
  45.